// NamedPipe.h: interface for the NamedPipe class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_NAMEDPIPE_H__003AAF28_18A2_40F5_A9AE_1D04E854FF9F__INCLUDED_)
#define AFX_NAMEDPIPE_H__003AAF28_18A2_40F5_A9AE_1D04E854FF9F__INCLUDED_
#include <Windows.h>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class Pipe
{
	public:
		virtual void SyncRead(LPVOID lpBuff, DWORD dwLength);
		virtual void SyncWrite(LPVOID lpBuff, DWORD dwLength);
	protected:
		HANDLE m_hPipe;
		Pipe();
};

class NamedPipeServerParams
{
public:
	DWORD dwOpenMode;
	DWORD dwPipeMode;
	DWORD nMaxInstance;
	DWORD nOutBufferSize;
	DWORD nInBufferSize;
	DWORD nDefaultTimeOut;
	LPSECURITY_ATTRIBUTES lpSecurityAttributes;
};

class DefaultNamedPipeServerParams : public NamedPipeServerParams
{
public:
	DefaultNamedPipeServerParams();
};

class SqlDebuggerNamedPipeServerParams : public DefaultNamedPipeServerParams
{
public:
	SqlDebuggerNamedPipeServerParams();
};


class NamedPipe : public Pipe
{
public:
	static NamedPipe * CreateServerAndConnect(LPCSTR lpName, NamedPipeServerParams params);
	static NamedPipe * CreateServer(LPCSTR lpName, NamedPipeServerParams params);
	static NamedPipe * ClientFromName(LPCSTR lpName);
	virtual ~NamedPipe();
	void Connect();
	void DisConnect();
protected:
	NamedPipe();
	NamedPipe(HANDLE hPipe, LPCSTR lpName);
	CHAR szName[256];

};
#endif // !defined(AFX_NAMEDPIPE_H__003AAF28_18A2_40F5_A9AE_1D04E854FF9F__INCLUDED_)
